/*
 * File: DocumentSet.java 
 *  
 * Created on 04.01.2011
 */
package de.graph.document;

import java.util.BitSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;


// experimental class
public final class DocumentSet implements Set<Document> {

    // TODO - BitSet kann nur int als Index - hmpf
    private final BitSet idSet;
    
    public DocumentSet() {
        this.idSet = new BitSet();
    }
    
    @Override
    public int size() {
        return idSet.length();
    }

    @Override
    public boolean isEmpty() {
        return idSet.isEmpty();
    }

    @Override
    public boolean contains(Object o) {
        if (o == null || o.getClass() != Document.class) {
            return false;
        }
        
        return idSet.get(((Document)o).getId().intValue());
    }

    @Override
    public Iterator<Document> iterator() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Object[] toArray() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public <T> T[] toArray(T[] a) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public boolean add(Document e) {
        idSet.set(e.getId().intValue());
        
        // TODO 
        return true;
    }

    @Override
    public boolean remove(Object o) {
        if (o == null || o.getClass() != Document.class) {
            return false;
        }
        
        idSet.clear(((Document)o).getId().intValue());
        
        // TODO 
        return true;
    }

    @Override
    public boolean containsAll(Collection< ? > c) {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public boolean addAll(Collection< ? extends Document> c) {
        // TODO - OR
        return false;
    }

    @Override
    public boolean retainAll(Collection< ? > c) {
        // TODO - AND
        return false;
    }

    @Override
    public boolean removeAll(Collection< ? > c) {
        // TODO - NAND
        return false;
    }

    @Override
    public void clear() {
        idSet.clear();
    }
}
